package com.margo.project.redis.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.margo.project.redis.model.RedisModel;
import com.margo.project.redis.service.RedisSetOperationsServiceImpl;

/**
 * https://blog.csdn.net/hjm4702192/article/details/80518856
 * @author fangxingbang
 *
 */
@Controller
@RequestMapping(value = "/sw/mobile/mobileservice/redisSetOperationsController")
public class RedisSetOperationsController {
    @Autowired
    private RedisSetOperationsServiceImpl<RedisModel> service;
    
    //添加
    @RequestMapping(value = "/add", method = RequestMethod.GET)
    @ResponseBody
    public void add() {
        System.out.println("start.....");
        RedisModel m = new RedisModel();
        m.setName("张三");
        m.setTel("1111");
        m.setAddress("深圳1");
        m.setRedisKey("zhangsanKey01");
        service.add(m);

        RedisModel m2 = new RedisModel();
        m2.setName("张三2");
        m2.setTel("2222");
        m2.setAddress("深圳2");
        m2.setRedisKey("zhangsanKey02");
        service.add(m2);

        RedisModel m3 = new RedisModel();
        m3.setName("张三3");
        m3.setTel("2222");
        m3.setAddress("深圳2");
        m3.setRedisKey("zhangsanKey03");
        service.add(m3);
    }
    
    //查询所有
    @RequestMapping(value = "/read", method = RequestMethod.GET)
    @ResponseBody
    public Object read() {
        return service.read();
    }
    
    //pop出栈
    @RequestMapping(value = "/pop", method = RequestMethod.GET)
    @ResponseBody
    public Object pop() {
        return service.pop();
    }
}
